/**
 * Created by tomkk on 2017/1/19.
 */
var express = require('express');
var router = express.Router();
var shell = require('shelljs');
router.post('/',function(req,res){
    var pwd = req.body.password;
    if(pwd !== 'tomkk'){
        console.warn("非法webhook请求");
        res.end("非法webhook请求");
        return;
    }
    console.log('接收到hook');
    shell.cd('~/nodejs/deployment/bin');
    shell.exec('git pull https://git.oschina.net/tomkk/deployment master');
    shell.exec('npm install');
    shell.exec('sudo pm2 restart www');
    console.log('自动部署成功');
})

module.exports = router;